<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改楼宇')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-building-edit" th:object="${building}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">所属社区：</label>
                <div class="col-sm-8">
                    <input autocomplete="off" class="form-control" type="text" name="sqName" onclick="selectDeptTree()" id="sqName" th:field="*{sqName}" required>
                    <!--之所以不用hidden是因为hidden不能被表单的reset()方法清除值-->
                    <input type="text" style="display: none;" name="sqCode" id="sqCode" th:field="*{sqCode}" >
                </div>
                <script type="text/javascript">
                    /* 用户管理-修改-选择部门树 */
                    function selectDeptTree() {
                        var deptId = $.common.isEmpty($("#sqCode").val()) ? "100" : $("#sqCode").val();
                        var url = ctx + "system/dept/selectDeptTree/" + deptId;
                        var options = {
                            title: '选择社区',
                            width: "380",
                            url: url,
                            callBack: doSubmit
                        };
                        $.modal.openOptions(options);
                    }
                    function doSubmit(index, layero){
                        var tree = layero.find("iframe")[0].contentWindow.$._tree;
                        if ($.tree.notAllowParents(tree)) {
                            var body = layer.getChildFrame('body', index);
                            $("#sqCode").val(body.find('#treeId').val());
                            $("#sqName").val(body.find('#treeName').val());
                            layer.close(index);
                        }
                    }
                </script>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">所属场所类型：</label>
                <div class="col-sm-8">
                    <select name="sscsLx" class="form-control m-b" th:with="type=${@dict.getType('b_zzslx')}" required >
                        <option value="">未选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sscsLx}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">所属场所名称：</label>
                <div class="col-sm-8">
                    <input name="sscsMc" th:field="*{sscsMc}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">楼号：</label>
                <div class="col-sm-8">
                    <input readonly="true" name="lh" th:field="*{lh}" class="form-control" type="text"
                            required>
                </div>
            </div>
            <div class="form-group" style="display: none;">
                <label class="col-sm-3 control-label">每栋拥有单元数：</label>
                <div class="col-sm-8">
                    <input name="dys" th:field="*{dys}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">总层数：</label>
                <div class="col-sm-8">
                    <input name="cs" th:field="*{cs}" class="form-control" type="text"
                           min="0" max="254" digits="true" title="只能输入0-254之间的正整数" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">每层拥有户数：</label>
                <div class="col-sm-8">
                    <input name="hs" th:field="*{hs}" class="form-control" type="text"
                           min="0" max="254" digits="true" title="只能输入0-254之间的正整数" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "place/building";
        $("#form-building-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-building-edit').serialize());
            }
        }
    </script>
</body>
</html>